Skip to content

Conversation

@xlauko
Copy link
Collaborator

@xlauko xlauko commented Aug 18, 2025

No description provided.

seven-mile and others added 30 commits August 10, 2025 19:44
…ity and maintainability (#1525)

As noted in [this
comment](#1442 (comment)),
the nested if-arms in `GlobalOpLowering` are somewhat confusing and
error-prone. This PR simplifies the logic into more straightforward
components.

Since LLVM's GlobalOp accepts two types of initializers (either an
initializer value or an initializer region), we've extracted the
decision logic into a separate function called `lowerInitializer`. This
function takes two inout arguments: `mlir::Attribute &init` (for the
attribute value) and `bool useInitializerRegion` (as the decision
indicator). All code paths then converge at a common epilogue that
handles the operation rewriting.

The previous implementation for lowering `DataMemberAttr` initializers
relied on recursion between MLIR rewrite calls, which made the control
flow somewhat opaque. The new version makes this explicit by using a
clear self-recursive pattern within `lowerInitializer`.
Fix #1371.

Not sure about whether we could remove `convertTypeForMem` completely.
Let's fix the doc first.
This change moves all declarations of emit* functions in
CIRGenFunction.h into a common location and sorts them alphabetically.
The goal of this change is to make it easier to keep upstream and
incubator code in a consistent location, making functions easier to find
for upstreaming and minimizing conflicts in the incubator when rebasing.

I did most of this sort manually, and I've probably been inconsistent in
how I treat sorting of uppercase versus lowercase. I made no attempt to
provide a rule for ordering different declarations of functions with the
same name. We can improve on that over time if anyone feels the need.

I tried very hard not to drop comments (one of the reasons I had to do
this manually), but I may have lost a few.

This change loses the grouping of some declarations that were co-located
by common purpose, but most of the declarations lacked a coherent
ordering, so I think this is a step forward overall.
This is a rebased version of the inactive PR #1380.

---------

Co-authored-by: koparasy <[email protected]>
Adds implementation for ATanOp's lowering ThroughMLIR.
Adds implementation for ACosOp's lowering ThroughMLIR.
Adds implementation for ASinOp's lowering ThroughMLIR.
In the review for upstreaming unary operation support
(llvm/llvm-project#131369), it was suggested
that the VisitPlus and VisitMinus functions should be combined. This is
a backport of that refactoring.
This also removes some unused `#include`s.

I choose to allow lowering to LLVM dialect when we're lowering CIR to
MLIR core dialects, because some operations don't have their
counterparts in these dialects (for example, `UnreachableOp ->
llvm.unreachable` and `LLVMIntrinsicCallOp -> cir.llvm.intr.xxx`). I
don't think we can delay them to the MLIR->LLVM pass as it seems we
assume all CIR operations have been lowered after CIR->MLIR conversion.

Co-authored-by: Yue Huang <[email protected]>
Update getZeroInitAttr to cover more FP types, Backport from
(llvm/llvm-project#133100)
Adds implementation for TanOp's lowering via ThroughMLIR.
Upstream commit changed behavior
llvm/llvm-project@ff585fe
I tested in original clang and it produced the same IR with clangir.
Related: #1497
…nmvq_f32 (#1546)

ower vminnmv_f32, vminnmvq_f64 and vminnmvq_f32
…#1547)

When a pointer variable is initialized with a null pointer, the AST
contains a NullToPointer cast. If we just emit a null pointer of the
correct type, we will miss any side effects that occur in the
initializer. This change adds code to emit the initializer expression if
it is not a simple constant.

This results in an extra null pointer constant being emitted when the
expression has side effects, but the constant emitted while visiting the
expression does not have the correct type, so the alternative would be
to capture the emitted constant and bitcast it to the correct type. An
extra constant seems less intrusive than an unnecessary bitcast.
#1552)

These entries exist in OG but are not present in CIR codegen.
Added:
- `cos`
- `floor`
- `round`
- `rint`
- `nearbyint`
- `sin`
- `sqrt`
- `tan`
- `trunc`
tommymcm and others added 25 commits August 13, 2025 14:31
Special handling for array of unions was forcing all non-union C arrays
to be emitted as CIR arrays, which differs from OG CodeGen, where array
may be emitted as LLVM struct.

Closes #1315
We were missing argument handling for `-fclangir-idiom-recognizer` on
its own, and were not propagating `-fclangir-lib-opt` for the clang
toolchain.
Failure:
```
calling convention does not permit calls
  call spir_kernel void @bar(ptr addrspace(1) %10)
fatal error: error in backend: Lowering from LLVMIR dialect to llvm IR failed!
```
This makes it on par with OG but does not add anything just yet (same NYI
asserts should fail).
This will enable handling for records (coming next)
This includes member data attribute in to enable and existing test.
LLVM lowering is follow up work.

Fixes XFAIL in ../clang/test/CIR/CodeGen/nonzeroinit-struct.cpp
This PR is inspired by the discussion in
#1745 (comment).
When changing the type of

```mlir
IndexAttr:$index,
I64Attr:$index
```

in `GetMemberOp`, the `getIndex` method becomes auto-generated.
This allows us to remove the custom builder previously defined for this
operation.
Backport AbstractConditionalOperator for ComplexType from the upstream

Fix: #1788
Previously, when an array of destructible object went out of scope, the
object destructors were called in the same order that they were
constructed. This is incorrect. The objects should be destructed in
reverse order. This change fixes that.

This fixes #1759
Backport LValueBitcast support for ComplexType from the upstream
@xlauko
Copy link
Collaborator Author

xlauko commented Aug 18, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@xlauko xlauko changed the title XXX [CIR] Record type constraints Aug 18, 2025
@lanza lanza force-pushed the main branch 2 times, most recently from 8acaf96 to 58135ea Compare October 20, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.